//引入懒加载插件
import { lazy } from "react"
//懒加载
//一级路由
let Index = lazy(() => import('../views/Index'))
let Login = lazy(() => import('../views/Login'))
let Detail = lazy(() => import('../views/Detail'))
let NotFound = lazy(() => import('../views/NotFound'))
let Register = lazy(() => import('../views/Register'))
let Search = lazy(() => import('../views/Search'))
let Collect = lazy(() => import('../views/Collect'))


//二级路由
let Home = lazy(() => import('../views/Index/Home'))
let Cart = lazy(() => import('../views/Index/Cart'))
let Goods = lazy(() => import('../views/Index/Goods'))
let Mine = lazy(() => import('../views/Index/Mine'))
let Shopcart = lazy(() => import('../views/Index/Shopcart'))




export default [
    {
        path: '/index',
        component: Index,
        children: [//二级路由
            {
                path: '/index/home',
                component: Home,
                exact: true
            },
            {
                path: '/index/goods',
                component: Goods,
                exact: true
            },
            {
                path: '/index/cart',
                component: Cart,
                exact: true
            },
            {
                path: '/index/mine',
                component: Mine,
                exact: true
            },
            {
                path: '/index/shopcart',
                component: Shopcart,
                exact: true
            },
            {
                from: '/index',
                to: '/index/home',
                redirect: true
            },
            {
                component: NotFound
            }
        ]
    },
    {
        path: '/login',
        component: Login,
        exact: true
    },
    {
        path: '/detail',
        component: Detail,
        exact: true
    },
    {
        path: '/collect',
        component: Collect,
        exact: true
    },
    {
        path: '/register',
        component: Register,
        exact: true
    },
    {
        path: '/search',
        component: Search,
        exact: true
    },
    {
        from: '/',
        to: '/index',
        redirect: true
    },
    {
        component: NotFound
    }
]